package com.rainbow.support.half.message.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.google.common.collect.Maps;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import java.util.Map;

/**
* 半事务消息实体
* @author 付为地
* 邮箱  1335157415@qq.com
* @date 2023-03-07 05:31:49
*/
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "半事务消息实体")
public class HalfMessagePayload<T> implements Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 * 分支事务id
	 */
	@NotNull
	@ApiModelProperty(value = "分支事务id", required = true)
	private String branchId;
	/**
	 * 全局事务id
	 */
	@NotNull
	@ApiModelProperty(value = "全局事务id", required = true)
	private String globalId;

	/**
	 * 消息主体
	 */
	@NotNull
	@ApiModelProperty(value = "消息主体", required = true)
	private T originBody;

	/**
	 * 发送人,消费者消费时默认用户
	 */
	@NotNull
	@ApiModelProperty(value = "发送人", required = true)
	private String creator;
	/**
	 * 发送时间,消费时凭此记录业务时间
	 */
	@NotNull
	@ApiModelProperty(value = "发送时间", required = true)
	private Date createTime;

	/**
	 * 业务类型
	 */
	@ApiModelProperty("业务类型")
	private String category;

	/**
	 * 业务扩展字段
	 */
	@ApiModelProperty("业务扩展字段")
	private String expandtag;

	/**
	 * 备注信息
	 */
	@ApiModelProperty(value = "备注信息")
	private String remark;

	/**
	 * 服务端点
	 */
	@ApiModelProperty("服务端点")
	private String endpoint;

	/**
	 * 服务链路
	 */
	@ApiModelProperty("服务链路")
	private String chainpath;


	/**
	 * 预留字段
	 */
	@ApiModelProperty("预留字段")
	private String reservetag;


	/**
	 * 本地事务,处理之前查询的参数
	 * 单独处理可以避免大事务问题
	 */
	@ApiModelProperty(value = "条件参数")
	@JSONField(serialize = false)
	private Map<String, Object> argsMap= Maps.newHashMap();
}
